<?PHP  
class emailer
{
	var $mail_name;
	var $mail_to;
	var $mail_sender;
	var $mail_from;
	var $mail_subject;
	var $mail_forward;
	var $mail_location;
	var $mail_date;
	var $mail_time;
	var $mail_headers;
	var $mail_message;
	var $mail_data;
	var $mail_reply_to;
	var $mode;


	function send_mail($mode)
	{
		
		$message = $this->mail_message; 
		
		global $conf;
		if($mode=='quick')
		{
			$to = $this->mail_to; 
			$subject = $this->mail_subject; 

				$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";

				$headers .= 'To: '.$to.' <'.$to.'>' . "\r\n";
				$headers .= 'From: '.$conf->a['site-name'].' <'.$conf->a['reply-to'].'>' . "\r\n";
				

		}
		else
		{
			$to = $this->mail_to; 
			$subject = $this->mail_subject; 

			
				$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";

				$headers .= 'To: '.$to.' <'.$to.'>' . "\r\n";
				$headers .= 'From: '.$conf->a['site-name'].' <'.$conf->a['reply-to'].'>' . "\r\n";
		}
		


		// Send 
		$mail = new PHPMailer(false); // the true param means it will throw exceptions on errors, which we need to catch
		$mail->SMTPDebug = false;
		$mail->do_debug = false; 
		$mail->IsSMTP(); // telling the class to use SMTP

		try {
			
			
			$mail->ContentType = 'text/plain'; 
			$mail->IsHTML(false);
		  $mail->Host       = "mail.pinoytuner.com"; // SMTP server
		  $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
		  $mail->SMTPAuth   = true;                  // enable SMTP authentication
		  $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
		  $mail->Host       = $conf->a['smtp-address'];      // sets GMAIL as the SMTP server
		  $mail->Port       = $conf->a['smtp-port'];                   // set the SMTP port for the GMAIL server
		  $mail->Username   = $conf->a['smtp-user'];  // GMAIL username
		  $mail->Password   = $conf->a['smtp-password'];            // GMAIL password
		  $mail->AddReplyTo($conf->a['reply-to'], $conf->a['site-name']);
		  $mail->AddAddress($to, $to);
		  $mail->SetFrom($conf->a['reply-to'], $conf->a['site-name']);
	
		  $mail->Subject = $subject;
		  $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
		  $mail->MsgHTML($message);

		  $mail->Send();
		  mp("Message Sent OK");
		
		} catch (phpmailerException $e) {
		  mp($e->errorMessage()); //Pretty error messages from PHPMailer
		} catch (Exception $e) {
		  mp($e->getMessage()); //Boring error messages from anything else!
		}
		
	}
	function sendemail()
	{

		
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		// Additional headers
		//$headers .= 'To: '. $this->mail_name .' <'. $this->mail_to .'>\r\n';
		$headers .= 'From: '. $this->mail_sender .' <'. $this->mail_from .'>' . "\r\n";
		
		$body = "<html>\n";
	    $body .= "<body style=\"font-family:Arial, Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
	    $body .= $this->mail_message.$mail_data;
		
	    $body .= "</body>\n";
	    $body .= "</html>\n";
		
		mail($this->mail_to, $this->mail_subject, $body, $headers); 
		return TRUE;
	}
	
	function collectallpost()
	{
		
			if ($_SERVER['REQUEST_METHOD'] == "POST") {
				foreach ($_POST as $key => $value) { 
					$msg .= ucfirst ($key) ." : ". $value . " <br />\n"; 
				}
			}
			else {
				foreach ($_GET as $key => $value) { 
					$msg .= ucfirst ($key) ." : ". $value . "<br /> \n"; 
				}
			}
			
			return $msg;
	}
}

?>